# 使用 Ubuntu 22 作为基础镜像
FROM ubuntu:22

# 设置中国镜像源
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list

# 安装 Python 3.8 和 PIP
RUN apt-get update && apt-get install -y python3.8 python3-pip

# 安装 openjdk-8-jdk
RUN apt-get install -y openjdk-8-jdk

# 安装 browsermob-proxy
RUN apt-get install -y browsermob-proxy

# 安装 Google Chrome
RUN apt-get install -y wget gnupg2
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list
RUN apt-get update && apt-get -y install google-chrome-stable

# 将 Python 应用源码复制到镜像中
COPY ../python /app

# 安装 Python 依赖
WORKDIR /app
RUN pip3 install -r requirements.txt

# 设置环境变量
ENV PYTHONPATH=/app

# 暴露端口
EXPOSE 8000

# 启动 Python Web 服务器
CMD [ "python3.8", "main.py" ]
